//
//  DALikeAndComment.m
//  DAKnowledge
//
//  Created by DreamArts on 16/6/24.
//  Copyright © 2016年 lidongyang. All rights reserved.
//

#import "DALikeAndComment.h"
#import "DALabel.h"
#import "Utility.h"
#import "DAHeader.h"


#define kViewHeight    self.frame.size.height
#define kButtonWidth   (self.frame.size.width - 1) / 2


@interface DALikeAndComment ()
//// 点赞的view
//@property (nonatomic, strong) UIView *likeView;
//@property (nonatomic, strong) UIImageView *likeImage;
//@property (nonatomic, strong) DALabel *likeLabel;
//@property (nonatomic) BOOL isSelectLikeView;
//// 评论的view
//@property (nonatomic, strong) UIView *commentView;
//@property (nonatomic, strong) UIImageView *commentImage;
//@property (nonatomic, strong) DALabel *commentLabel;
//// 中间的线
//@property (nonatomic, strong) UIView *lineView;


@property (nonatomic, strong) UIView *lineView;


@end
@implementation DALikeAndComment

+ (DALikeAndComment *)shareDALikeAndComment{
    static DALikeAndComment *likeAndComment = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        likeAndComment = [[DALikeAndComment alloc]init];
        likeAndComment.backgroundColor = [UIColor themeBlackColor];
    });
    return likeAndComment;
}


- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.cornerRadius = 5;
        
        self.likeButton = [UIButton buttonWithType:UIButtonTypeCustom];
        self.likeButton.backgroundColor = [UIColor themeBlackColor];
        [self.likeButton setTitle:@"赞" forState:UIControlStateNormal];
        self.likeButton.titleLabel.font = [UIFont systemFontOfSize:10];
        [self.likeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.likeButton addTarget:self action:@selector(clickLikeButton) forControlEvents:UIControlEventTouchUpInside];
        self.likeButton.layer.cornerRadius = 5;
        [self addSubview:self.likeButton];
        
        self.commentButton = [UIButton buttonWithType:UIButtonTypeCustom];
        self.commentButton.backgroundColor = [UIColor themeBlackColor];
        [self.commentButton setTitle:@"评论" forState:UIControlStateNormal];
        self.commentButton.titleLabel.font = [UIFont systemFontOfSize:10];
        [self.commentButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.commentButton addTarget:self action:@selector(clickCommentButton) forControlEvents:UIControlEventTouchUpInside];
        self.commentButton.layer.cornerRadius = 5;
        [self addSubview:self.commentButton];
        
        self.lineView = [[UIView alloc]init];
        self.lineView.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.lineView];
    }
    return self;
}


- (void)layoutSubviews{
    self.likeButton.frame = CGRectMake(0, 0, kButtonWidth, kViewHeight);
    self.lineView.frame = CGRectMake(self.likeButton.frame.origin.x + self.likeButton.frame.size.width, 5, 0.5, kViewHeight - 10);
    self.commentButton.frame = CGRectMake(self.lineView.frame.origin.x + self.lineView.frame.size.width, 0, kButtonWidth, kViewHeight);
}
- (void)clickLikeButton{
    NSLog(@"点赞");
    
}

- (void)clickCommentButton{
    NSLog(@"评论");
    // 发送通知
    [[NSNotificationCenter defaultCenter] postNotificationName:@"ClickCommentView" object:nil];
    self.hidden = YES;
    [[NSNotificationCenter defaultCenter] postNotificationName:@"isChangeSelect" object:nil];
    
    
    [self.delegate ClickCommentView];
    
}








/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
